#include "StaticData.h"

USING_NS_CC;
using namespace std;

const string static_data_path = "static_data.plist";
StaticData* StaticData::_instance=0;

StaticData::StaticData():_staticDataPath(static_data_path)
{
}

StaticData::~StaticData()
{
}

bool StaticData::init()
{
	_dataHashMap=CCDictionary::createWithContentsOfFile(_staticDataPath.c_str());
	CC_SAFE_RETAIN(_dataHashMap);
	return true;
}

StaticData* StaticData::getInstance()
{
	if(!_instance){
		static StaticData staticData;
		staticData.init();
		_instance=&staticData;
	}
	return _instance;
}

const char* StaticData::stringFromKey( std::string key )
{
	return _dataHashMap->valueForKey(key)->getCString();
}

int StaticData::intFromKey( std::string key )
{
	return _dataHashMap->valueForKey(key)->intValue();
}

float StaticData::floatFromKey( std::string key )
{
	return _dataHashMap->valueForKey(key)->floatValue();
}

bool StaticData::booleanFromKey( std::string key )
{
	return _dataHashMap->valueForKey(key)->boolValue();
}

cocos2d::CCPoint StaticData::pointFromKey( std::string key )
{
	return CCPointFromString(_dataHashMap->valueForKey(key)->getCString());
}

cocos2d::CCRect StaticData::rectFromKey( std::string key )
{
	return CCRectFromString(_dataHashMap->valueForKey(key)->getCString());
}

cocos2d::CCSize StaticData::sizeFromKey( std::string key )
{
	return CCSizeFromString(_dataHashMap->valueForKey(key)->getCString());
}
